<?php
if(!empty($_POST)){
    $mathematics=$_POST['txt1'];
    $chinese=$_POST['txt2'];
    // $mathematics=parseint($mathematics);
    // $chinese=parseint($mathematics);
    if(($mathematics>=0 && $mathematics<=100)&&($chinese>=0 && $chinese<=100)){
        $avg=($mathematics+$chinese)/2;
        switch ($avg){
            case $avg>=90:         
                echo 'A';
                break;
            case $avg>=80:
                echo 'B';
                break;
            case $avg>=70:
                echo 'C';
                break;
            case $avg>=60:
                echo 'D';
                break;
            case $avg>=50:
                echo 'E';
                break;
            case $avg<50:
                echo 'F';
                break;
        } 
    }else{
        echo "数学与语文成绩只能在0~100之间";
    }
    
}  
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<form action="" method="post">
语文: <input type="text" name="txt1"><br>
数学: <input type="text" name="txt2"><br>
<input type="submit" value="判断成绩">
</form>
</body>
</html>
